#include "tree.h"

bool start( char *fn )
{
	CUTextFile file( fn, "r" );
	if( file.IsOpen() == false )	return false;

	int now_line=0;
	int num_error=0;
	int num_node=0;
	while(1)	{
		CUString line;
		if( file.ReadLine( line ) == false ) break;
		now_line++;


		CTree t;
		t.Init();
		if( t.LoadTree( line ) == false )	{
			num_error++;
			continue;
		}

		num_node += t.num_node;

	}

	fprintf( stdout, "num_sent:\t%d\n", now_line );
	fprintf( stdout, "num_node:\t%d\n", num_node );
	fprintf( stdout, "num_err :\t%d\n", num_error);


	return true;
}


int main( int argc, char *argv[] )
{
	if( argc != 2 )	{
		fprintf( stderr, "usage: parsestat parse-file\n" );
		return 1;
	}

	if( start( argv[1] ) == false )	{
		return 1;
	}

	return 0;
}


